package com.main.crossdomaineventmanagement.event.core;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.LocalTransactionState;
import org.apache.rocketmq.client.producer.TransactionListener;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;

@Slf4j
public class TransactionListenerImpl implements TransactionListener {
    @Override
    public LocalTransactionState executeLocalTransaction(Message msg, Object arg) {
        // 执行本地事务逻辑（数据库操作）
        log.error("事务消息发生异常，执行本地事务逻辑 {},{}",msg,arg);
        return LocalTransactionState.COMMIT_MESSAGE;
    }

    @Override
    public LocalTransactionState checkLocalTransaction(MessageExt msg) {
        // 检查本地事务状态
        log.error("事务消息发生异常，检查本地事务状态 {}",msg);
        return LocalTransactionState.COMMIT_MESSAGE;
    }
}